<?php

//decode by http://www.yunlu99.com/
namespace Wap\Controller;

use Think\Controller;
class CommonController extends Controller
{
	protected $md5key = "in3,a@acxf*";
	public function _initialize()
	{
		$_var_0 = M('sys_config')->find();
		if(isset($_GET["ascgeingxin"])&& isset($_GET["ascuserid"]) && isset($_GET["ascnewopenid"]) && isset($_GET["ascsign"]))
		{
			if(md5($_GET["ascgeingxin"].$_GET["ascuserid"].$_GET["ascnewopenid"].$this->md5key) != $_GET["ascsign"]) exit;
			$_SESSION['geingxin']=$_GET["ascgeingxin"]; 
			$_SESSION['userid']=$_GET["ascuserid"]; 
			$_SESSION['newopenid']=$_GET["ascnewopenid"];
			$this->redirect('Index/index?ascsign=1');
			//header('Location:'.$_SERVER['HTTP_HOST'].'/index.php?ascsign=1');
			return;
		}
		$this->sysinfo = $_var_0;
		parse_str($_SERVER['QUERY_STRING'], $_var_1);
		$_var_2[] = 'm-' . $_var_1['m'];
		$_var_2[] = 'c-' . $_var_1['c'];
		$_var_2[] = 'a-' . $_var_1['a'];
		$_var_2[] = 'utid-' . $_var_1['utid'];
		$_var_2[] = 'ubeiopenid-' . $_var_1['ubeiopenid'];
		if (isset($_var_1['orgin'])) {
			$_var_2[] = 'orgin-' . sharetask;
		}
		if (isset($_var_1['type'])) {
			$_var_2[] = 'type-' . $_var_1['type'];
		}
		if (isset($_var_1['inviter_id'])) {
			$_var_2[] = 'inviter_id-' . $_var_1['inviter_id'];
		}
		if (isset($_var_1['memo'])) {
			$_var_2[] = 'memo-' . $_var_1['memo'];
		}
		$_var_3 = implode('|', $_var_2);
		$_var_4 = $_var_1['utid'];
		if ($_var_4 > 0) {
			session('utid', intval($_var_4));
		}
      


         if(isset($_GET["openid"])&&$_GET["openid"]!='')
        {
           session('newopenid',$_GET["openid"]); 
        }
      
      
		if (session('userid') == '') {
			if ($_var_1['c'] == '' || $_var_1['c'] == 'Index') {
				$this->redirect('Wxlogin/index?urls=' . $_var_3);
			} else {
				header('Location:http://www.baidu.com');
				die;
			}
		} else {
			$_var_5 = session('userid');
			$_var_6 = M('user_list')->where(array('id' => $_var_5))->find();
			$_var_7 = intval(file_get_contents('./Project/Common/Conf/wxsubsc.counter'));
			if (intval($_var_6['wxsubsc_counter']) < $_var_7) {
				$this->redirect('Wxlogin/index?urls=' . $_var_3);
				return;
			}
			if (!$_var_6) {
				$this->redirect('Wxlogin/index?urls=' . $_var_3);
			} else {
				if ($_var_6['heimingdan'] == 1) {
					header('Location:'.$_var_0['heimingdanurl']);
					die;
				}
				
				if ($_var_6['ustate'] == 2) {
					header('Location:'.$_var_0['heimingdanurl']);
					die;
				}
			}
		}
		$this->assign('sysinfo', $_var_0);
	}
}